// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   OrderStatusAction.java

package com.boci.clientapp.orderstatus.action;

import com.boci.clientapp.main.ApplicationService;
import com.boci.clientapp.main.MainPanel;
import com.boci.clientapp.orderstatus.*;
import com.boci.clientapp.orderstatus.handler.OrderDetailHandler;
import com.boci.clientapp.orderstatus.handler.OrderStatusHandler;
import com.boci.clientapp.orderstatus.vo.OrderStatusDetailVO;
import com.boci.common.action.AbstractAction;
import com.boci.common.constant.RequestTypeConst;
import com.boci.common.util.AppException;
import com.boci.common.util.StringUtil;
import java.util.Date;
import java.util.HashMap;
import java.util.logging.Logger;

public class OrderStatusAction extends AbstractAction
{

    public OrderStatusAction()
    {
    }

    private void doRefreshOrderStatus(HashMap pInpMap, String pActionType)
        throws Exception
    {
        if(pActionType.equals("GO") || pActionType.equals("REFRESH"))
        {
            String strReqType = RequestTypeConst.BOCI_ORDER_STATUS_URL;
            String strModName = "ORDER_STATUS_MODULE";
            String strScrName = "ORDER_STATUS_SCREEN";
            OrderStatusScrPanel orderStatusScrPanel = (OrderStatusScrPanel)appServ.getMainPanel().getPanel(strModName, strScrName);
            pInpMap.put("submit_ref", "xxx");
            OrderStatusHandler orderStatusHandler = new OrderStatusHandler(strReqType);
            com.boci.common.vo.ResponseVO responseVO = orderStatusHandler.getOrderStatus(pInpMap);
            orderStatusScrPanel.setLastUpdateDateTime(new Date());
            orderStatusScrPanel.updateAllLastUpdateTime();
            orderStatusScrPanel.refresh(responseVO);
            int intSelectedIndex = orderStatusScrPanel.getSelection();
            orderStatusScrPanel.showOrderStatusTable(intSelectedIndex);
        }
    }

    public void doProcess(HashMap pInpMap, String pActionType)
    {
    	try{
	        appServ.setBusy(true);
	        if(pActionType.equals("GO") || pActionType.equals("REFRESH"))
	            doRefreshOrderStatus(pInpMap, pActionType);
	        else
	        if(pActionType.equals("CHANGE_EDIT"))
	            doOrderChangeEdit(pInpMap, pActionType);
	        else
	        if(pActionType.equals("CANCEL_REVIEW"))
	            doOrderCancelReview(pInpMap, pActionType);
	        else
	        if(pActionType.equals("DETAIL"))
	            doOrderDetail(pInpMap, pActionType);
    	}
        catch(AppException appEx)
        {
            if(pActionType.equals("GO") || pActionType.equals("REFRESH"))
                doRefreshOrderStatusTable();
            appServ.showErrorDialog(null, appEx.getMessage());
        }
        catch(Exception sysEx)
        {
            logger.severe(StringUtil.formatException(sysEx));
            appServ.showSysErrDialog();
        }
        finally
        {
            appServ.setBusy(false);
        }
        return;
    }

    private void doOrderDetail(HashMap pInpMap, String pActionType)
        throws Exception
    {
        if(!pActionType.equals("DETAIL"))
            return;
        String strReqType = RequestTypeConst.BOCI_ORDER_DETAIL_URL;
        String strModName = "ORDER_STATUS_MODULE";
        String strOrderDetailScrName = "ORDER_STATUS_DETAIL";
        OrderStatusDetailVO orderStatusDetailVO = (OrderStatusDetailVO)pInpMap.get("SELECTED_VO");
        if(orderStatusDetailVO == null)
        {
            return;
        } else
        {
            HashMap inHashMap = new HashMap();
            inHashMap.put("str", orderStatusDetailVO.getOrderId());
            OrderDetailHandler orderDetailHandler = new OrderDetailHandler(strReqType);
            com.boci.common.vo.ResponseVO responseVO = orderDetailHandler.getOrderDetail(inHashMap);
            OrderDetailScrPanel orderDetailScrPanel = (OrderDetailScrPanel)appServ.getMainPanel().getPanel(strModName, strOrderDetailScrName);
            appServ.getMainPanel().showScreen(strModName, strOrderDetailScrName);
            orderDetailScrPanel.refresh(responseVO);
            return;
        }
    }

    private void doOrderCancelReview(HashMap pInpMap, String pActionType)
        throws Exception
    {
        if(!pActionType.equals("CANCEL_REVIEW"))
            return;
        String strReqType = RequestTypeConst.BOCI_ORDER_DETAIL_URL;
        String strModName = "ORDER_STATUS_MODULE";
        String strOrderCancelReviewScrName = "ORDER_STATUS_CANCEL_REVIEW";
        OrderStatusDetailVO orderStatusDetailVO = (OrderStatusDetailVO)pInpMap.get("SELECTED_VO");
        if(orderStatusDetailVO == null)
        {
            return;
        } else
        {
            OrderCancelReviewScrPanel orderCancelReviewScrPanel = (OrderCancelReviewScrPanel)appServ.getMainPanel().getPanel(strModName, strOrderCancelReviewScrName);
            appServ.getMainPanel().showScreen(strModName, strOrderCancelReviewScrName);
            orderCancelReviewScrPanel.refresh(orderStatusDetailVO);
            return;
        }
    }

    private void doOrderChangeEdit(HashMap pInpMap, String pActionType)
        throws Exception
    {
        if(!pActionType.equals("CHANGE_EDIT"))
            return;
        String strReqType = RequestTypeConst.BOCI_ORDER_DETAIL_URL;
        String strModName = "ORDER_STATUS_MODULE";
        String strOrderChangeEditScrName = "ORDER_STATUS_CHANGE_EDIT";
        OrderStatusDetailVO orderStatusDetailVO = (OrderStatusDetailVO)pInpMap.get("SELECTED_VO");
        if(orderStatusDetailVO == null)
        {
            return;
        } else
        {
            OrderChangeEditScrPanel orderChangeEditScrPanel = (OrderChangeEditScrPanel)appServ.getMainPanel().getPanel(strModName, strOrderChangeEditScrName);
            appServ.getMainPanel().showScreen(strModName, strOrderChangeEditScrName);
            orderChangeEditScrPanel.refresh(orderStatusDetailVO);
            return;
        }
    }

    public void doRefreshOrderStatusTable()
    {
        String strModName = "ORDER_STATUS_MODULE";
        String strScrName = "ORDER_STATUS_SCREEN";
        OrderStatusScrPanel orderStatusScrPanel = (OrderStatusScrPanel)appServ.getMainPanel().getPanel(strModName, strScrName);
        orderStatusScrPanel.refresh(null);
        orderStatusScrPanel.showOrderStatusTable(orderStatusScrPanel.getSelection());
    }
}
